<?php
class Country extends CActiveRecord
{
    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'shop_country';
    }
    
    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('name, zone_id', 'required'),
            array('zone_id', 'numerical', 'integerOnly' => true),
            array('name', 'length', 'max' => 45),
            array('name, code', 'safe'),
            // The following rule is used by search().
            // @todo Please remove those attributes that should not be searched.
            array('country_id, name, code, zone_id', 'safe', 'on' => 'search'),
        );
    }
    
    public function relations()
    {
        return array('zone' => array(self::BELONGS_TO, 'ShopZone', 'zone_id'));
    }

    /**
     * Returns the static model of the specified AR class.
     * Please note that you should have this exact method in all your CActiveRecord descendants!
     * @param string $className active record class name.
     * @return Products the static model class
     */
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }
}
